home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / snip9611.zip / PCNVRT.H < prev    next >
C/C++ Source or Header  |  1996-11-24  |  732b  |  26 lines

  1. /* +++Date last modified: 09-Feb-1996 */
  2.  
  3. /*
  4. **  demo code for converting Pascal strings to/from C strings
  5. **
  6. **  public domain by Bob Stout
  7. */
  8.  
  9. #include <string.h>
  10. #include "sniptype.h"
  11.  
  12. #define P2Cconvert(s) do \
  13.             {UCHAR n = *(s); memmove((s), &(s)[1], n); s[n] = '\0';} while(0)
  14. #define C2Pconvert(s) do\
  15.             {int n = strlen(s); memmove(&(s)[1], (s), n); *(s) = n;} while(0)
  16.  
  17. #if (0)                             /* Demo code fragment follows */
  18.  
  19.       char string[81];
  20.  
  21.       fgets(string, 81, inFile);    /* get 80-char C string       */
  22.       C2Pconvert(string);           /* convert it in place        */
  23.       P2Cconvert(string);           /* convert back               */
  24.  
  25. #endif
  26.